package com.zzxx.exam.ui;

import com.zzxx.exam.entity.ExamInfo;
import com.zzxx.exam.entity.QuestionInfo;
import com.zzxx.exam.entity.User;


import javax.swing.*;
import java.awt.*;
import java.sql.Time;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 前端控制器
 */
public class ClientContext {
    private WelcomeWindow welcomeWindow;
    private LoginFrame loginFrame;
    private ExamFrame examFrame;
    private MenuFrame menuFrame;

    private MsgFrame msgFrame;
    private ExamInfo examInfo;


    public WelcomeWindow getWelcomeWindow() {
        return welcomeWindow;
    }

    public void setWelcomeWindow(WelcomeWindow welcomeWindow) {
        this.welcomeWindow = welcomeWindow;
    }

    public LoginFrame getLoginFrame() {
        return loginFrame;
    }

    public void setLoginFrame(LoginFrame loginFrame) {
        this.loginFrame = loginFrame;
    }

    public ExamFrame getExamFrame() {
        return examFrame;
    }

    public void setExamFrame(ExamFrame examFrame) {
        this.examFrame = examFrame;
    }

    public MenuFrame getMenuFrame() {
        return menuFrame;
    }

    public void setMenuFrame(MenuFrame menuFrame) {
        this.menuFrame = menuFrame;
    }

    public MsgFrame getMsgFrame() {
        return msgFrame;
    }

    public void setMsgFrame(MsgFrame msgFrame) {
        this.msgFrame = msgFrame;
    }

    public ExamInfo getExamInfo() {
        return examInfo;
    }

    public void setExamInfo(ExamInfo examInfo) {
        this.examInfo = examInfo;
    }

    //程序一打开就打开界面
    public void showView(){
        loginFrame.setVisible(true);
    }


    public void login(){
        //1.收集数据：loginFrame界面获得
        /**
         * 想要获得loginFrame中id和password
         * loginFrame提供一个对外的方法
         */
        int id = loginFrame.getId();
        String pwd = loginFrame.getPwd();
        //2。调用业务模型
        if(id == 1000 && pwd.equals("1234")){
            menuFrame.updateView("张三");
            //界面切换 -> MenuFrame界面(true)
            menuFrame.setVisible(true);
            //当前界面设置为(false)
            loginFrame.setVisible(false);
        }
    }

    //退出界面
    public void exit(JFrame source ) {
        int i = JOptionPane.showConfirmDialog(source, "确定要离开吗?");
        // 判断点击的是 确定还是取消
        if (i == JOptionPane.OK_OPTION) {
            System.exit(0);
        }
    }

}

